
#ifndef _ROOM_H_
#define _ROOM_H_

#include <cstdlib>
#include <iostream>

#include "common.h"

#include "BaseShape.h"

__BEGIN_NAMESPACE_DECL_

class RoomTexture
{
    public:
        RoomTexture (unsigned int texId=0,
                     double sMax=0, 
                     double tMax=0);
        friend class Room;
    private:
        unsigned int _texId;
        double _sMax, _tMax;
};

class Room : public BaseShape
{
    public:
        // Constructor(s)
        Room(unsigned int subdiv=16);

        // Destructor
        virtual ~Room() { } 

        // Interface implementation for Shape superclass
        virtual void draw ();
        // set textures (floor, walls, ceiling)
        void setFloorTexture     (const RoomTexture& tex);
        void setFrontWallTexture (const RoomTexture& tex);
        void setBackWallTexture  (const RoomTexture& tex);
        void setLeftWallTexture  (const RoomTexture& tex);
        void setRightWallTexture (const RoomTexture& tex);
        void setCeilingTexture   (const RoomTexture& tex);
        // enable/disable textures
        void setUseTexture       (bool useTextures);
        // set subdivisions
        void setSubdivisions     (unsigned int subdiv);
        unsigned int getSubdivisions ();

    protected:
        bool _useTextures;
        unsigned int _subdiv;
        RoomTexture _floor, _front, _back, _left, _right, _ceil;

    private:
        static void DrawSubdividedRectangle(double x1, double y1, 
                                            double x2, double y2,
                                            unsigned int subdiv, 
                                            const RoomTexture& tex);
};

__END_NAMESPACE_DECL_

#endif
